package com.wuzy.sys.controller;

import com.wuzy.sys.model.SysPermission;
import com.wuzy.sys.service.SysPermissionService;
import com.wuzy.sys.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 菜单操作Controller
 * Created by wuzy
 * on 2017-03-27 21:13.
 */
@Controller
@RequestMapping("/sys/menu")
public class SysMenuController {
    @Autowired
    private SysPermissionService permissionService;
    /**
     * 获取当前用户的菜单
     */
    @RequestMapping("/getByPid")
    @ResponseBody
    public Result getByPid(){
        Result result=new Result();
        List<SysPermission> menuByPIdList =permissionService.getMenuByPId(0L);
        if(null==menuByPIdList || menuByPIdList.size()<=0){//
            result.setCode(Boolean.FALSE);
            result.setMessage("菜单加载失败！");
        }else{
            result.setCode(Boolean.TRUE);
            result.setData(menuByPIdList);
        }
        return result;
    }

}
